import type {
  CultivationSkillItemConfig,
  EquipmentItemConfig,
  ITEM_TYPE,
  ItemRarity,
  MaterialItemConfig,
} from '../../data/item/type';
import type { ConditionProgress } from '../../systems/condition-checker/type';
import type { AttributeType } from '../attributes/type';

export interface EquipmentInventorySlotItemPayloadBaseAttrs {
  prop: AttributeType;
  value: number;
}

export interface EquipmentInventorySlotItemPayloadEnhance {
  level: number;
  /** 强化失败时增加的保护点 */
  failProtection: number;
}

export interface EquipmentInventorySlotItemPayload {
  rarity: ItemRarity;
  baseAttrs: EquipmentInventorySlotItemPayloadBaseAttrs[];
  enhance: EquipmentInventorySlotItemPayloadEnhance;
}

export interface InventorySlotItemPayload {
  /** 装备相关属性 */
  equip?: EquipmentInventorySlotItemPayload;
}

export interface InventorySlotItem {
  id: string;
  itemId: string;
  quantity: number;
  payload?: InventorySlotItemPayload;
}

export interface BaseInventorySlotInfoItem<T extends string = string> {
  type: T;
  ins: InventorySlotItem;
}

export interface CultivationSkillInventorySlotInfoItem
  extends BaseInventorySlotInfoItem<typeof ITEM_TYPE.CULTIVATION_SKILL> {
  canLearn: boolean;
  studyConditionProgress: ConditionProgress[];
  itemConfig: CultivationSkillItemConfig;
}

export interface EquipmentInventorySlotInfoItem
  extends BaseInventorySlotInfoItem<typeof ITEM_TYPE.EQUIPMENT> {
  itemConfig: EquipmentItemConfig;
}

export interface MaterialInventorySlotInfoItem
  extends BaseInventorySlotInfoItem<typeof ITEM_TYPE.MATERIAL> {
  itemConfig: MaterialItemConfig;
}

export type InventorySlotInfoItem =
  | CultivationSkillInventorySlotInfoItem
  | EquipmentInventorySlotInfoItem
  | MaterialInventorySlotInfoItem;

export interface InventoryState {
  slots: (InventorySlotInfoItem | null)[];
  /** 容量 */
  capacity: number;
  /** 使用的容量 */
  useCapacity: number;
}

export interface TempSlot {
  id: string;
  createdAt: number;
  ins: InventorySlotItem;
}
